package com.example.springboottools.utils;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.poi.excel.sax.handler.RowHandler;
import org.apache.poi.ss.usermodel.Sheet;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class HuToolExcelUtil {
    public static void main(String[] args) {
        List<Object> resultMap = new ArrayList<>();
        ExcelUtil.readBySax("D:\\staples\\日常记录\\工作记录\\2024\\03\\商品新增上架\\接口开发\\测试数据\\测试模板\\新增上架数据.xls",1, createRowHandler(resultMap));
        System.out.println(resultMap);
    }
    private static RowHandler createRowHandler(List<Object> resultMap) {
        return new RowHandler() {
            @Override
            public void handle(int sheetIndex, int rowIndex, List<Object> rowList) {
                Console.log("[{}] [{}] {}", sheetIndex, rowIndex, rowList);
                for (Object o : rowList) {
                    resultMap.add(o);
                }
            }
        };
    }



}
